package com.balabala.gym_system.mapper;

import com.balabala.gym_system.pojo.dto.RoleQueryDto;
import com.balabala.gym_system.pojo.entity.Role;
import com.balabala.gym_system.pojo.vo.RoleListVo;
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import org.apache.ibatis.annotations.Select;

import java.util.List;

/**
 * Author:zl
 * Date:2023/5/1 17:10
 */

public interface RoleMapper extends BaseMapper<Role> {

    /**
     * 角色列表模糊查询
     * @param roleQueryDto
     * @return
     */
    List<RoleListVo> findRoleByQueryDto(RoleQueryDto roleQueryDto);


    /**
     * 根据管理员id查询对应角色
     * @param adminId
     * @return
     */
    @Select("SELECT r.id,r.name  FROM tb_admin_role ar," +
            "tb_role r WHERE ar.role_id = r.id  AND ar.admin_id =#{adminId}")
    List<Role> findRoleByAdminId(Long adminId);
}
